Laravel / Model / Relation : join with multiple fields
Model Relation with multiple fields
-
STEP
class Route extends Model { use Compoships; public function trips() { return $this->hasMany('Trip', ['id', 'route_name', 'source_file'], ['route_id', 'route_name', 'source_file']); } } class Trip extends Model { use Compoships; public function route() { return $this->belongsTo('Route', ['route_id', 'route_name', 'source_file'], ['id', 'route_name', 'source_file']); } }